#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string s;
    cin>>s;
    int ans=0;
    ans+=s.size();
    for(int i=1;i<s.size();i++)
    {
        int x=s[i-1]-'0',y=s[i]-'0';
        if(x<y)x+=10;
        ans+=x-y;
    }
    ans+=s[s.size()-1]-'0';
    cout<<ans;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}